﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Data;

namespace Wala.Infrastructure.Converters
{
    public sealed class TimespanToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            long timespan;
            string timeString = string.Empty;

            if (long.TryParse(value.ToString(), out timespan))
            {
                DateTime date = new DateTime(1970, 1, 1).AddSeconds(timespan);
                timeString = date.ToString("ddd, dd/MM/yyyy hh:mm");
            }
            return timeString;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            // TODO: Implement this method
            throw new NotImplementedException();
        }
    }
}
